﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Htxw.AMFRemoting;
using System.Net;

namespace DotNetRemotingTest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                RemoteObject rmt = new RemoteObject();
                //rmt.Connect("192.168.1.100", 2000);
                //rmt.Connect("172.18.2.58", 2000);

                rmt.Connect(Dns.GetHostName(), 2000);
                DateTime tick = DateTime.Now;
                ArrayList cars = new ArrayList();
                for (int k = 0; k < 200; k++)
                    cars.Add(1001090803);

                for (int i = 0; i < 1000; i++)
                {
                   //object ret = rmt.CallDirect("CDataInterface", "GetGPSData",
                    //   new object[] { 1001090803, DateTime.Now.AddMinutes(-5), DateTime.Now });
                    object ret = rmt.CallDirect("CDataInterface", "Test1",
                        new object[] { "1001090803", 33, 55.3 });

                   //object ret = rmt.CallDirect("CDataInterface", "GetGPSDataArray",
                   //    new object[] { cars, DateTime.Now.AddMinutes(-5), DateTime.Now });

                    this.label1.Text = i.ToString() + "" + ret.ToString();
                    Application.DoEvents();
                }
                TimeSpan span = (DateTime.Now - tick);
                this.label1.Text = "used time :" + ((float)span.TotalMilliseconds)/1000 + "(S)";

                rmt.CloseConnect();
            }
            catch (Exception ee)
            {
                this.label1.Text = ee.Message;
            }
        }
    }
}
